import tesserocr
from PIL import Image

image_to_parse = Image.open("test.png")
## 灰度化
image_to_convert = image_to_parse.convert('L')
image_to_convert.show()
thershold = 50
chart = []
for i in range(256):
    if i < thershold:
        chart.append(0)
    else:
        chart.append(1)
image_for_thershold = image_to_convert.point(chart, '1')
image_for_thershold.show()
text_result = tesserocr.image_to_text(image_for_thershold)
print(text_result)